import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
// 全局样式
import './assets/css/global.css';

import {get, post} from "./api/axios";
import {hasAdmin, hasManager, hasRole, userId, user} from "./utils/hasRole";

Vue.use(ElementUI);

Vue.config.productionTip = false;

// Vue 定义自定义指令:防止按钮重复提交
Vue.directive('avoidMultiClick', {
  inserted(el, binding) {
    el.addEventListener('click', () => {
      if (!el.disabled) {
        el.disabled = true;
        setTimeout(() => {
          el.disabled = false
        }, binding.value || 1000)
      }
    })
  }
});

/* 全局post */
Vue.prototype.$post = post;
/* 全局get */
Vue.prototype.$get = get;

/* 权限校验 */
Vue.prototype.$hasAdmin = hasAdmin();
Vue.prototype.$hasManager = hasManager();
Vue.prototype.$hasRole = hasRole();
Vue.prototype.$userId = userId();
Vue.prototype.$user = user();


new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app');
